#ifndef LANEITEM_H
#define LANEITEM_H

#include <QObject>
#include <QGraphicsPolygonItem>
#include <QDebug>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>

#include "commondefine.h"


class LaneItem : public QObject, public QGraphicsPolygonItem
{
    //如果需要信号和槽，必须继承QObject
    Q_OBJECT

public:
    explicit LaneItem(QObject *parent = nullptr);

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;

    void setRoadId(const std::string &qstrRoadId);
    std::string getRoadId() const;
    void setRoadType(const std::string &strRoadType);
    std::string getRoadType() const;

    void setLaneSection(const SLaneSection &laneSection);
    const SLaneSection &getLaneSection() const;

    QString getId() const;
    void setId(const QString &qstrId);
    QString getLaneType() const;
    void setLaneType(const QString &qstrLaneType);
    QString getRoadMarkType() const;
    void setRoadMarkType(const QString &qstrRoadMarkType);
    QString getRoadMarkColor() const;
    void setRoadMarkColor(const QString &qstrRoadMarkColor);
    SGeometry getGeometry() const;
    void setGeometry(const SGeometry &geometry);
    void appendWidth(int iId, const Width &width);
    Width getWidth(int iId);
    double getLaneSectionS() const;
    void setLaneSectionS(double dLaneSectionS);
    Height getLaneHeight() const;
    void setLaneHeight(const Height &height);

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;

private:
    std::string m_qstrRoadId;
    std::string m_qstrRoadType;

    SLaneSection m_laneSection;

    QString m_qstrId;
    QString m_qstrLaneType;
    QString m_qstrRoadMarkType;
    QString m_qstrRoadMarkColor;
    SGeometry m_geometry;
    QMap<int, Width> m_qmapWidth;  //所属车道段同方向所有车道的车道id和对应的width
    double m_dLaneSectionS;  //所属车道段S坐标
    Height m_height;  //车道高度信息

signals:
    void sigLane(LaneItem*, const QPointF &pointf);
    void sigClick();
};

#endif // LANEITEM_H
